
import os
ROOT_PATH=os.path.abspath(os.path.dirname(os.getcwd()))
ROOT_TXT_PATH=ROOT_PATH+"/stock_py/SData/"
class StockSingle:
    _instance = None
    _flag = True
    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
        return cls._instance   # 返回的是内存地址

    def __init__(self):
        if StockSingle._flag:  # 如果init 没有执行
            self._uindex=0
            self.haoshi=0
            self._trade_date_now=''
            self.trade_stock_now_file_path=''
            self.f = None
            self._stock_bk_rps=None
            self._RPS3_CODES=[]
            self._RPS5_CODES=[]
            self._RPS20_CODES=[]
            StockSingle._flag = False  # 表示执行过init

    @property
    def uindex(self):
        return self._uindex
    
    @uindex.setter
    def uindex(self,a):
        self._uindex = a

    @property
    def stock_bk_rps(self):
        return self._stock_bk_rps
    
    @stock_bk_rps.setter
    def stock_bk_rps(self,a):
        self._stock_bk_rps = a

    @property
    def trade_date_now(self):
        return self._trade_date_now

    @trade_date_now.setter
    def trade_date_now(self,date):
        self._trade_date_now = date
        self.trade_stock_now_file_path = ROOT_TXT_PATH+date+"-rps.txt"
        self.f = open(self.trade_stock_now_file_path, "w+",encoding='utf8') 

    @property
    def RPS3_CODES(self):
        return self._RPS3_CODES
    
    @RPS3_CODES.setter
    def RPS3_CODES(self,a):
        self._RPS3_CODES = a
        
    @property
    def RPS5_CODES(self):
        return self._RPS5_CODES
    
    @RPS5_CODES.setter
    def RPS5_CODES(self,a):
        self._RPS5_CODES = a
        
        
    @property
    def RPS20_CODES(self):
        return self._RPS20_CODES
    
    @RPS20_CODES.setter
    def RPS20_CODES(self,a):
        self._RPS20_CODES = a






